Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development
Data management in the SDO
When the database query is opened, a batch of rows is read into the
RowObjecttemp-table on the server-side SDO, as illustrated in Figure 10–1. This temp-table is then returned to the client-side SDO as an output parameter to theserverSendRowsprocedure call. This client-side temp-table can then be browsed by SmartDataBrowsers, and individual row values are displayed in one or more SmartDataViewers.Figure 10–1: Reading the first batch of rows into the SDO
![]()
Once the
RowObjecttable has been passed to the client, the server-side copy is emptied in preparation for reading another batch of rows from the database. When the SDO is running in a stateless AppServer session, the norm for deployed Progress Dynamics applications, the server-side SDO is deleted to free the session for another user. If another batch of data is requested, the server-side SDO restarts, the query reopens, and repositions. The data is read from the database into the server-sideRowObjecttable, passed to the client, and appended to the client-sideRowObjecttable. The client-side query on theRowObjecttable is reopened and repositioned to the new current row (the first row of the new batch). If there is a SmartDataBrowser, the reopening of theRowObjectquery automatically refreshes the browser.Remember that all records are read from the database
NO-LOCK. This is because there is simply no way to keep record locks on a set of records that is being passed to another Progress session. The SDO code checks to make sure that another user has not modified any updated row, since it was read. Also, there are functions to refresh the data set or the current row if that is desired. Figure 10–2 shows this process.Figure 10–2: Reading the second batch of rows into the SDO
![]()
To collect changes to send back to the server, there is a separate copy of the
RowObjecttemp-table calledRowObjUpd. When the user updates an existing row two things happen. First, a row is created in theRowObjUpdtable and the original values of the modified row are copied there. This before image of the row allows the SDO to determine later in the process whether another user has changed the row since this user read it. Second, the changes are saved to theRowObjecttable on the client, and a special flag field, calledRowMod,is set toU(forupdate) to indicate that the row has changed.The
RowModfield in the before-image record in theRowObjUpdtable is set to blank, as shown in Figure 10–3.Figure 10–3: Modifying customer 5 in the client SDO
![]()
If the user adds (or copies) a new row, the data is written to the
RowObjecttable, with aRowModcode ofA(orC). It might seem puzzling that the changes are first written to theRowObjecttable on the client rather than to theRowObjUpdtable. The reason for this is that any changes need to be visible to the user before they are committed. Thus, they must be made to the table the client objects are browsing (theRowObjecttable). As discussed below, all the changes are moved into theRowObjUpdtable onCommit.When a user deletes a row, it is also necessary to reflect this in the
RowObjecttable, so that the row appears to be truly gone from the user’s session. For this reason, when aDeleteoccurs, the row to be deleted is moved to theRowObjUpdtable with aRowModofD, and it is deleted from theRowObjecttable.The diagram shown in Figure 10–4 reflects an
Addand aDeletedone within the same transaction as the firstUpdate.Figure 10–4: Adding row 9 and deleting row 6 after updating row 5
![]()
By default, each individual change (a
Saveof anUpdate, orSaveof anAdd/Copy, or aDelete) goes back to the server-side SDO to be committed to the database. If there is a Commit Panel, however, theAutoCommitSDO property that controls this causes changes to be accumulated in the client-side SDO untilCommitis done. Then they all go back to the server together.When a
Commitoccurs (either immediately when the user chooses Save if there is no Commit Panel or Commit band in the toolbar, or otherwise when the user chooses), the following happens on the client:
- Updated rows are copied from the
RowObjecttable to theRowObjUpdtable; thus there is a before image of each modified row (with aRowModof “”) and an after image (with aRowModofU).- Added or copied rows are copied from the
RowObjecttable to theRowObjUpdtable.- The
RowObjUpdtable is passed to the server-side SDO as an argument to theserverCommitprocedure.The following then happens on the server-side SDO:
- Any
preTransactionValidateprocedure is run to handle business logic that should occur before the actual database transaction begins.- The database transaction is started.
- Any
beginTransactionValidateprocedure is run to handle business logic that should occur inside the transaction but before the changes themselves are written to the database.- The updated row is written back to the database. Each updated row has a
RowIdentfield in theRowObjUpdtable that holds theROWIDrecords of the database records the row was derived from. The database records are readEXCLUSIVE-LOCKand compared with the before record in the table. If another user has changed the database record, the current change is rejected, unless theCheckCurrentChangedSDO instance property has been set toNO. If nothing has failed so far, those fields that were modified are assigned back to the corresponding database records.- The added row is created in the database and its values assigned.
- The row marked to be deleted is read from the database and deleted.
- Any
endTransactionValidateprocedure in the SDO is executed to handle business logic that should occur inside the database transaction but after all the modifications are made to the database, as follows:
![]()
- The updated and added rows are re-read from the database, to capture any changes made by database triggers or other code (such as the assigning of a key field value by a
CREATEtrigger, or the calculation of a field by aWRITEtrigger, or by one of theTransactionValidateprocedures).- Any
postTransactionValidateprocedure is executed on the server.- The final versions of the possibly modified updated and added rows are passed back to the client, and the final versions are copied back into the
RowObjecttable to be displayed in the client.Note: When- The server-side
RowObjUpdtable is emptied.AutoCommitis enabled and changes in one SDO trigger aCommitaction, all unsaved changes in all the SBO’s SDO’s are saved.The following happens on the client:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |